package cn.qvtu.web.utility;

import cn.qvtu.web.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;

@Component
public class LoginUtils {

    @Autowired
    public HttpServletRequest request;

    public boolean isLogin(){
        Object loginUser = request.getSession().getAttribute("loginUser");
        return loginUser!=null;
    }

    public User getLoginUser(){
        Object loginUser = request.getSession().getAttribute("loginUser");
        if(loginUser instanceof User){
            return (User)loginUser;
        }
        return null;
    }
}
